home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
BASIC
/
0006.ZIP
/
POKEPEEK.TXT
< prev
next >
Wrap
Text File
|
1984-03-11
|
7KB
|
210 lines
03/03/84
COMMONLY USED BASIC PEEKS, POKES AND SUBROUTINES
DUE TO THE LACK OF A COMPREHENSIVE, PUBLISHED DIRECTORY OF COMMONLY USED
POKES, PEEKS AND SUBROUTINES THIS LIST HAS BEEN COMPILED BY THE SMUG
PROSIG AS WELL AS A MANY OTHER HARDWORKING PD SOURCES. THANKS AND A TIP
OF THE HAT TO ALL CONTRIBUTORS! ADDITIONS TO THE LIST ARE ENCOURAGED AND
SHOULD BE ADDRESS TO:
DON WATKINS, CIS IBMSIG 76003,252
THERE ARE, OF COURSE NO WARRENTIES OR GUARENTEES THAT ANY OF STUFF WORKS
AND FURTHERMORE, IF IT BLOWS UP YOUR MACHINE IT AIN'T MY FAULT.
------------------------------------------------------------------------
BY SPECIFYING A DEF SEG=&H40 IN ANY BASIC PROGRAM, IT IS POSSIBLE TO
REFERENCE THE FOLLOWING VECTORS (FIELDS) IN THE ROM BIOS AREA BY USING A
PEEK FUNCTION AND THE FOLLOWING OFFSETS FROM THE CURRENT SEGMENT AS
DEFINED BY THE DEF SEG STATEMENT.
&H0 - RS232 ADDRESSES ON YOUR IBM PC.
THIS WILL ALLOW YOU TO TELL HOW MANY (UP TO
FOUR) ASYNC CARDS ARE ATTACHED, IF ANY.
&H8 - PRINTER ADDRESSES ON YOUR IBM PC.
THIS WILL TELL YOU WHAT PRINTER ADDRESSES,
AND HOW MANY (UP TO FOUR) EXIST. EACH IS
ADDRESSED BY A TWO BYTE HEX VALUE.
&H10 - EQUIPMENT FLAG.
THIS FIELD DESCRIBES THE SETTING OF THE
OPTIONS SWITCHES. IT DESCRIBES WHAT OPTIONAL
DEVICES ARE ATTACHED TO THE SYSTEM. THE
FOLLOWING LISTS THE BIT-SIGNIFICANCE OF THIS
FIELD:
BIT 0 - INDICATES THAT THERE ARE DISKETTE
DRIVES ON THE SYSTEM.
BIT 1 - NOT USED.
BIT 2,3 - PLANAR RAM SIZE (00=16K 10=32K 01=48K
11=64K)
BIT 4,5 - INITIAL VIDEO MODE (00=UNUSED
10=40X25 COLOR
01=80X25 COLOR
11=80X25 MONO)
BIT 6,7 - NUMBER OF DISKETTE DRIVES (00=1 10=2
01=3 11=4) ONLY IF BIT 0 = 1.
BIT 8 - UNUSED
BIT 9,10,11 - NUMBER OF RS232 CARDS ATTACHED
BIT 12 - GAME I/O ATTACHED
BIT 13 - NOT USED
BIT 14,15 - NUMBER OF PRINTERS ATTACHED
&H13 - MEMORY SIZE IN K BYTES.
&H15 - I/O RAM SIZE IN K BYTES.
&H17 - KEYBOARD FLAG -- THE FOLLOWING LISTS THE MASKS
SET TO DESCRIBE CURRENT KEYBOARD STATUS:
BYTE 1;
&H80 - INSERT STATE ACTIVE
&H40 - CAPS LOCK STATE HAS BEEN TOGGLED
&H20 - NUM LOCK STATE HAS BEEN TOGGLED
&H10 - SCROLL LOCK STATE HAS BEEN TOGGLED
&H08 - ALTERNATE SHIFT KEY DEPRESSED
&H04 - CONTROL SHIFT KEY DEPRESSED
&H02 - LEFT SHIFT KEY DEPRESSED
&H01 - RIGHT SHIFT KEY DEPRESSED
BYTE 2;
&H80 - INSERT KEY IS DEPRESSED
&H40 - CAPS LOCK KEY IS DEPRESSED
&H20 - NUM LOCK KEY IS DEPRESSED
&H10 - SCROLL LOCK KEY IS DEPRESSED
&H08 - SUSPEND KEY HAS BEEN TOGGLED
&H49 - CURRENT CRT MODE
&H00 - 40X25 BW
&H01 - 40X25 COLOR
&H02 - 80X25 BW
&H03 - 80X25 COLOR
&H04 - 320X200 COLOR
&H05 - 320X200 BW
&H06 - 640X200 BW
&H07 - 80X25 B&W CARD -- SPECIALIZED USE, USED
INTERNAL TO THE VIDEO ROUTINES.
&H4A - NUMBER OF CRT COLUMNS
&H50 - CURSOR POSITION (ONE OF EIGHT)
&H60 - CURRENT CURSOR MODE
&H6C - LOW WORD OF TIMER COUNT
&H6E - HIGH WORD OF TIMER COUNT
&H71 - &H07 - BREAK KEY DEPRESSED
&HFA6E - BEGINNING OF CHARACTER REGEN MEMORY
&HFF53 - PRTSC ROUTINE ADDRESS
------------------------------------------------------------------
REAL STUFF--
TOGGLE NUM LOCK
DEG SEG = &H40 : POKE &H17, PEEK(&H17) OR 32 'TO TURN ON
DEG SEG = &H40 : POKE &H17, PEEK(&H17) AND 223 'TO TURN OFF
TOGGLE CAPS LOCK
DEG SEG = &H40 : POKE &H17, PEEK(&H17) OR 64 'TO TURN ON
DEG SEG = &H40 : POKE &H17, PEEK(&H17) AND 171 'TO TURN OFF
SET SCROLL WINDOW
10 DEF SEG : POKE 91,20 : POKE 92,25 'SETS UP WINDOW ON LINE
20 LOCATE X,20 'FORCE CURSOR TO WINDOW
SET WINDOW WIDTH
DEF SEG : POKE 41,30 'SETS WINDOW WIDTH TO 30
RESTORE FUNCTION KEYS TO DEFAULT
10 DEF SEG = &HFACE
20 K = 1
30 I = 13
40 T$ = STRING$(13,32): J = 1
50 T1 = PEEK(I):IF T1 < 0 THEN MID$(T$,J,1) = CHR$(T1):J = J + 1:
I = I + 1 : GOTO 50
60 KEY K,LEFT$(T$,J-1):IF K <10 THEN K = K + 1: I = I + 1: GOTO 40 :
ELSE KEY ON
DETERMINE MONITOR TYPE
10 DEF SEG = 0
20 MONITOR.TYPE = PEEK(&H410) AND &H40
30 IF MONITOR.TYPE = 1 PRINT "40 X 25 COLOR"
40 IF MONITOR.TYPE = 32 PRINT "80 X 25 COLOR"
50 IF MONITOR.TYPE = 48 PRINT "MONOCHROME"
DETERMINE AMOUNT OF MEMORY INSTALLED (ONLY WORKS FOR GREATER THAN 48K)
DEF SEG = 0: MEMORY% = PEEK(&H413)+(256*PEEK(&H414))
OR, PUT ANOTHER WAY:
MEMORY INFO: DEF SEG=0
((PEEK(1040) AND 12) + 4 ) * 4 - MEMORY ON MOTHER-BOARD
PEEK(1045) + 256 * PEEK(1046) - EXPANSION MEMORY (ADD ON)
PEEK(1043) + 256 * PEEK(1044) - TOTAL MEMORY
READ DRIVE SWITCHES
DEF SEG = 0: NUMBER.OF.DRIVES% = PEEK(&H410) AND &HC0
CURRENT DISK INFO: DEF SEG=64
DEF SEG=64
PEEK(69) - TRACK
PEEK(70) - HEAD
PEEK(71) - SECTOR
256^PEEK(72) - BYTES PER SECTOR
DETERMINE IF GAME ADAPTER EXISTS
10 DEF SEG = 0: GAME.ADAPTER% = PEEK(&H411) AND &H10
20 IF GAME.ADAPTER% = 0 THEN GAME.ADAPTER$ = "NO" ELSE GAME.ADAPTER$
= "YES --INSTALLED"
KEYBOARD STUFF
TO DISABLE ENTIRE KEYBOARD: DEF SEG=64: OUT 97,204
TO RE-ENABLE KEYBOARD: DEF SEG=64: OUT 97,76
PRINTER STATUS--- AT LEAST ON EPSON ---
DEF SEG=64
A=PEEK(8)+256*PEEK(9)
B=(INP(A+1) AND 248) XOR 72
IF (B AND 128)<>128 THEN PRINTER OFF LINE ELSE ON LINE
INITIALIZE PRINTER: DEF SEG: OUT A+2,8
OUT A+2,12
NOTE: THE A TO INITIALIZE IS FROM PRINTER STATUS ROUTINE
A SHORT PROGRAM TO DISABLE AND RE-ENABLE CTRL BREAK FOLLOWS.
100 DIM OLD%(4)
110 DEF SEG=0
120 ' SAVE THE OLD CONTROL BREAK ADDRESS
130 FOR I=&H6C TO &H6F
140 OLD%(I-&H6C)=PEEK(I)
150 NEXT
160 ' ESTABLISH NEW CONTROL BREAK ADDRESS (POINT TO IRET)
170 POKE &H6C,&H53
180 POKE &H6D,&HFF
190 POKE &H6E,&H0
200 POKE &H6F,&HF0
210 DEF SEG
220 ' RESET OLD CONTROL BREAK ADDRESS
230 DEF SEG=0
240 FOR I=&H6C TO &H6F
250 POKE I,OLD%(I-&H6C)
260 NEXT
SAVE AND RESTORE A SCREEN IMAGE
1 DEF SEG = &HB800 'SAVE SCREEN IMAGE...CHANGE FOR
2 INPUT FILENAME$ 'MONOCHROME.
3 BSAVE FILENAME$,0,&H4000
1000 INPUT "FILENAME";FILENAME$ 'RESTORE IMAGE
1010 CLS
1020 DEF SEG = &HB800 'CHANGE TO &HB000 TO MONO
1030 BLOAD FILENAME$
NICE TO KNOW
BASIC UNPROTECT
ENTER BASICA
TYPE BSAVE "UN.P",1124,1
LOAD "MYPROG
BLOAD "UN.P",1124
THE PROGRAM CAN NOW BE LISTED, EDITED AND SAVED AS A NORMAL FILE.
THE LIST IS GROWING BUT COULD BE LONGER! ANY AND ALL ADDITIONS OF
COMMONLY USED SUBROUTINES AND PEEK/POKE LOCATIONS WILL BE GLADLY ADDED.
ADDRESS ALL ADDITIONS TO: DON WATKINS CIS 76003,252 (IBMSIG). WITH A
BIT OF YOUR ASSISTANCE THIS DOCUMENT CAN BECOME AN EFFECTIVE TOOL FOR THE
BASIC PROGRAMMER.... SO CHIP IN.